Skip to content

MySQL: Support the BINARY attribute on character columns - #3101

Open
VanshajPoonia wants to merge 1 commit into
apache:mainfrom
VanshajPoonia:feat/mysql-binary-attr-3037
Open

VanshajPoonia wants to merge 1 commit into
apache:mainfrom
VanshajPoonia:feat/mysql-binary-attr-3037

Conversation

@VanshajPoonia

Copy link
Copy Markdown

Dialects: MySQL

Closes #3037

CREATE TABLE t (c CHAR(1) BINARY) currently fails with:
Expected: ',' or ')' after column definition, found: BINARY

MySQL accepts BINARY after a character column type. It is shorthand for the binary collation of the column's character set. Syntax reference: https://dev.mysql.com/doc/refman/8.0/en/string-type-syntax.html

This PR adds Dialect::supports_binary_column_attribute() (default false, true for MySqlDialect) and a ColumnOption::Binary variant that displays as BINARY (API change). It is a column option because that was the smaller change. BINARY also works with NOT NULL and CHARACTER SET.

Tests are in tests/sqlparser_mysql.rs. They cover the AST, the round trip and the error on dialects without the flag.

AI assistance (Claude Code) was used to write the change and its tests.
I reviewed the diff and this PR description manually.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

MySqlDialect rejects the BINARY attribute following a character column type in CREATE TABLE.

1 participant